{% extends 'layout.html' %}
{% load teach %}
{% block css %}
    <style>
        table {
            font-size: 12px;
        }

        .panel-body {
            font-size: 12px;
        }

        table .title {
            display: block
        }

        tr.active {
            background-color: #f1f7fd;
            border-left: 3px solid #fdc00f;
        }
    </style>
{% endblock %}

{% block content %}

    <div class="luffy-container">
        <div class="col-md-3 course-area">
            <div class="panel panel-default">
                <!-- Default panel contents -->
                <div class="panel-heading">
                    <i class="fa fa-address-book-o" aria-hidden="true"></i> 课程

                    <a href="{% advanced_url request 'teach:course_add' %}" class="right btn btn-success btn-xs"
                       style="padding: 2px 8px;margin: -3px;">
                        <i class="fa fa-save" aria-hidden="true"></i>
                        新建
                    </a>
                </div>

                <table class="table table-hover">
                    <thead>
                    <tr>
                        <th>课程名称</th>
                        <th class="text-center">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for row in course_queryset %}

                        <tr class="{% is_active cid row.id %}">
                            <td>
                                <a class="title" href="?cid={{ row.id }}">{{ row.caption }}</a>
                            </td>
                            <td class="text-center">
                                <a href="{% advanced_url request 'teach:course_edit' cid=row.id %}" class="color-edit">
                                    <i class="fa fa-edit" aria-hidden="true"></i>
                                </a>
                                <span class="split">|</span>
                                <a href="{% advanced_url request 'teach:course_del' cid=row.id %}" class="color-del">
                                    <i class="fa fa-trash-o" aria-hidden="true"></i>
                                </a>
                            </td>
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>

            </div>
        </div>

        <div class="col-md-3 module-area">
            <div class="panel panel-default">
                <!-- Default panel contents -->
                <div class="panel-heading">
                    <i class="fa fa-book" aria-hidden="true"></i> 模块

                    {% if cid %}
                        <a href="{% advanced_url request 'teach:module_add' cid=cid %}"
                           class="right btn btn-success btn-xs"
                           style="padding: 2px 8px;margin: -3px;">
                            <i class="fa fa-save" aria-hidden="true"></i>
                            新建
                        </a>
                    {% endif %}

                </div>
                <table class="table table-hover">
                    <thead>
                    <tr>
                        <th>模块名称</th>
                        <th class="text-center">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for row in module_queryset %}
                        <tr class="{% is_active mid row.id %}">
                            <td>
                                <a class="title" href="?cid={{ cid }}&mid={{ row.id }}">{{ row.title }}（{{ row.daily_set.count }}）</a>
                            </td>
                            <td class="text-center">
                                <a href="{% advanced_url request 'teach:module_edit' cid=cid mid=row.id %}"
                                   class="color-edit">
                                    <i class="fa fa-edit" aria-hidden="true"></i>
                                </a>
                                <span class="split">|</span>
                                <a href="{% advanced_url request 'teach:module_del' cid=cid mid=row.id %}"
                                   class="color-del">
                                    <i class="fa fa-trash-o" aria-hidden="true"></i>
                                </a>
                            </td>
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>

            </div>
        </div>

        <div class="col-md-6 permission-area">

            <div class="panel panel-default">
                <!-- Default panel contents -->
                <div class="panel-heading">
                    <i class="fa fa-sitemap" aria-hidden="true"></i> 日计划
                    {% if cid %}
                        <a href="{% advanced_url request 'teach:daily_add' cid=cid %}"
                           class="right btn btn-success btn-xs"
                           style="padding: 2px 8px;margin: -3px;">
                            <i class="fa fa-save" aria-hidden="true"></i>
                            新建
                        </a>
                    {% endif %}
                </div>
                {% if mid %}
                    <div class="panel-body">
                        <form class="form-horizontal" method="post" novalidate>
                            {% csrf_token %}
                            {% for field in daily_form %}
                                <div class="form-group form-group-sm">
                                    <label for="{{ field.id_for_label }}"
                                           class="col-sm-2 control-label">{{ field.label }}</label>
                                    {% if forloop.last %}
                                        <div class="col-sm-6">
                                            {{ field }}
                                            {{ field.errors.0 }}
                                        </div>
                                        <div class="col-sm-4">
                                            <input type="submit" class="btn btn-primary btn-sm" value="快速新建">
                                        </div>
                                    {% else %}
                                        <div class="col-sm-10">
                                            {{ field }}
                                            {{ field.errors.0 }}
                                        </div>
                                    {% endif %}
                                </div>
                            {% endfor %}
                        </form>
                    </div>
                {% endif %}
                <table class="table">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>名称</th>
                        <th>类型</th>
                        <th class="text-center">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for row in daily_queryset %}
                        <tr>
                            <td>{{ forloop.counter }}</td>
                            <td>
                                <a href="{% advanced_url request 'teach:daily_prev' did=row.id %}">{{ row.title }}</a>
                            </td>
                            <td>{{ row.get_sec_type_display }}</td>
                            <td class="text-center">
                                <a href="{% advanced_url request 'teach:daily_edit' cid=cid did=row.id %}"
                                   class="color-edit">
                                    <i class="fa fa-edit" aria-hidden="true"></i>
                                </a>
                                <span class="split">|</span>
                                <a href="{% advanced_url request 'teach:daily_del' cid=cid did=row.id %}"
                                   class="color-del">
                                    <i class="fa fa-trash-o" aria-hidden="true"></i>
                                </a>
                            </td>
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>

{% endblock %}